import 'package:elephant_fish/model/rank_entity.dart';
import 'package:elephant_fish/model/rank_year_entity.dart';
import 'package:elephant_fish/util/size_util.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import 'charm_rank_list.dart';

class RankCardList extends StatefulWidget {
  final RankEntity rankEntity;

  const RankCardList({Key key, this.rankEntity}) : super(key: key);

  @override
  _RankCardListState createState() => _RankCardListState();
}

class _RankCardListState extends State<RankCardList> {
  ScrollController _scrollController = ScrollController();

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        widget.rankEntity.arr.length > 0
            ? Container(
                width: 345,
                height: 50,
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.only(
                      topLeft: Radius.circular(SizeUtil.px(18)),
                      topRight: Radius.circular(SizeUtil.px(18))),
                  gradient: LinearGradient(
                    begin: Alignment.topCenter,
                    end: Alignment.bottomCenter,
                    colors: [Color(0xfffe4d4e), Color(0xffff2d8f)],
                  ),
                ),
                child: Center(
                    child: Text(
                  widget.rankEntity.giftName + '榜',
                  style: TextStyle(
                    color: Color(0xffffffff),
                  ),
                )),
              )
            : Text(
                '',
                style: TextStyle(
                  color: Color(0xffffffff),
                ),
              ),
        Container(
          width: 345,
          decoration: BoxDecoration(
            borderRadius: BorderRadius.only(
                bottomLeft: Radius.circular(SizeUtil.px(18)),
                bottomRight: Radius.circular(SizeUtil.px(18))),
            gradient: LinearGradient(
              begin: Alignment.topCenter,
              end: Alignment.bottomCenter,
              colors: [Color(0xff221641), Color(0xff661e38)],
            ),
          ),
          child: ListView.builder(
              itemCount: widget.rankEntity.arr.length,
              controller: _scrollController,
              shrinkWrap: true,
              itemBuilder: (context, index) {
                return CharmRankList(
                  anchor: widget.rankEntity.arr[index],
                );
              }),
        )
      ],
    );
  }
}
